<template>
	<view class="content">
		{{title}}
		<view class="button-demo">
			<u-button :ripple="true" @click="chosepic">选择图片</u-button>
			<u-button :ripple="true" @click="chosefile">选择视频</u-button>
		</view>
		<video class="video" id="dd" :src="audiosrc"></video>
		<view v-for="(item,index) in chosedpic">
			<text>{{item.src}}</text>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title: 'Hello',
				chosedpic:[],
				videosrc:'',
				audiosrc:''
			}
		},
		onLoad() {
			try{
				const value = uni.getStorageSync('phone');
				if(value){
					this.title = value;
					uni.getStorage({
						key:'yzm',
						success:function(res){
							console.log(res.data);
						}
					})
				}else{
					uni.navigateTo({
						url:"../login/login"
					})
				}
			}catch(e){
					
			}
		},
		onShow() {
			this.chosedpic.forEach(
				(value,index,array)=>{
					console.log(value.src)
				}
			)
			uni.$on("chosefile",function(data){
				
			})
		},
		methods: {
			chosepic(){
				uni.navigateTo({
					url:"./chosepic"
				})
			},
			chosefile(){
				uni.chooseVideo({
					count:2,
					sourceType:['camera','album'],
					success:(res)=>{
						this.videosrc = res.tempFilePath;
						console.log(this.videosrc);
					}
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	.video{
		height: 300rpx;
		width: 500rpx;
	}
	.content{
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		padding: 40rpx;
	}
	.logo{
		height: 200rpx;
		width: 200rpx;
		margin-top: 100rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}
	.text-area{
		display: flex;
		justify-content: center;
	}
	.title{
		font-size: 28rpx;
		color: $u-content-color;
	}
	.button-demo{
		margin-top: 80rpx;
	}
	.link-demo{
		margin-top: 80rpx;
	}
</style>
